<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String url = request.getScheme() + "://" + request.getServerName()
			+ request.getRequestURI();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<title>权限管理2223</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<!-- modal页固定调用 -->
		<%@ include file="/html/custom/header.jsp"%>
		<%@ include file="/html/custom/modalHeader.jsp"%>


		<!-- 本页使用 -->
		<link type="text/css" href="<%=basePath%>/html/css/gm/popedom.css"
			rel="stylesheet" />
	<style>
			.datagird span{width: 100px;}
			.datagird th a{display: inline; vertical-align: middle; }
			.datagird span a{border: 1px solid #ffffff; vertical-align: middle; }
			.sub-box{border: 1px solid #cecece; float: left; position: relative; margin: 27px 10px 0 0; background-color: white; }
			.datagird .sub-title{ width:100px; margin:0; position: absolute; top: -20px; left:5px;background-color: white; border: 1px solid #cecece; border-bottom: 0; padding: 2px 5px;}
			.datagird .sub-title  a{border: 0; padding: 0 5px; border: 1px solid white;white-space:nowrap; }
			.p-list{padding: 3px;}
		</style>
		<script type="text/javascript">
			$(function(){
				function selectEvent(obj) {
					if ($(obj).attr("checked")) {
						$("#box_" + $(obj).val()).find("input").attr("checked",
								true);
					} else {
						$("#box_" + $(obj).val()).find("input").attr("checked",
								false);
					}
				
				}
				
				function selectParent(obj){
					var subId=$(obj).attr("data-parent");
					var modId=$("#chk_"+subId).attr("data-parent");
					if ($(obj).attr("checked")) {
						$("#chk_"+subId).attr("checked",true);
						$("#chk_"+modId).attr("checked",true);
					}else{
						
					}
				}

			$("input[name='rolePopedomList.popedomId']").click(function() {
						if(parseInt($(this).attr("data-type"),10)<3){
							selectEvent(this);
						}else{
							selectParent(this);
						}
					});
			});
		</script>
	</head>

	<body>
	
		<div id="content">

			<div class="datagird">
				<!-- formid 固定 -->
				<s:form id="formSave" namespace="/user" action="savePopes">
					<input type="hidden" name="rolePopedom.roleId"
						value="<s:property value="#request.rolePopedom.roleId" />" />

					<table class="ui-widget ui-widget-content">
						<thead>
							
						</thead>
						<tbody>
							<s:iterator value="#request.popedomList" id="mod" >
								<s:if test="type==1" >
								<tr class="ui-widget-header ">
									<th>
										<label>
										<input id="chk_<s:property value="#mod.id" />" name="rolePopedomList.popedomId" type="checkbox" value="<s:property value="#mod.id" />" data-type="<s:property value="#mod.type" />" 
										<s:iterator value="#request.rolePopedomList" id="myPope">
														<s:if test="#myPope.popedomId==#mod.id">
															checked="checked"
														</s:if>
													</s:iterator>  /> 	
										</label>				
										<a id="btnModPope_<s:property value="id" />" title="<s:property value="description" />" href="javascript:;" >[<s:property value="queue" />]<s:property value="popedomName" /></a>

									</th>

								</tr>
								<tr>
									<td id="box_<s:property value="#mod.id" />" >
										<s:iterator value="#request.popedomList" id="sub" >
											<s:if test="(#sub.type==2)&&(#sub.parent==#mod.id)" >
												<div class="sub-box" >
													<span class="sub-title" >
														<label>
														<input id="chk_<s:property value="#sub.id" />" name="rolePopedomList.popedomId" type="checkbox" value="<s:property value="#sub.id" />" data-type="<s:property value="#sub.type" />"
														<s:iterator value="#request.rolePopedomList" id="myPope2">
														<s:if test="#myPope2.popedomId==#sub.id">
															checked="checked"
														</s:if>
														</s:iterator>
														data-parent="<s:property value="#sub.parent" />" 
														 /> 
														</label>
														<a title="<s:property value="#sub.description" />"  id="btnModPope_<s:property value="#sub.id" />_0_<s:property value="#mod.id" />" href="javascript:;">(<s:property value="#sub.queue" />)<s:property value="#sub.popedomName" /></a>
														
													</span>
													<div  class="p-list" id="box_<s:property value="#sub.id" />" >
														<s:iterator value="#request.popedomList" id="pope" >
															<s:if test="(#pope.type==3)&&(#pope.parent==#sub.id)">
																<span >
																	<label>
																	<input name="rolePopedomList.popedomId" type="checkbox" value="<s:property value="#pope.id"  />"
																	<s:iterator value="#request.rolePopedomList" id="myPope3">
																		<s:if test="#myPope3.popedomId==#pope.id">
																			checked="checked"
																		</s:if>
																	</s:iterator>
																	data-type="<s:property value="#pope.type" />" 
																	data-parent="<s:property value="#pope.parent" />" />

																	</label>
																	<a title="<s:property value="#pope.description" />"  id="btnModPope_<s:property value="#pope.id" />_<s:property value="#sub.id" />_<s:property value="#mod.id" />" href="javascript:;"><s:property value="#pope.queue" />.<s:property value="#pope.popedomName" /></a>
																	
																</span>
															</s:if>
														</s:iterator>
													</div>
												</div>
											</s:if>
										</s:iterator>
									
									</td>
								</tr>
								</s:if>
							</s:iterator>


						</tbody>
					</table>
				</s:form>
			</div>

		</div>

		<!-- modal也固定页尾 （按钮） -->
		<div class="btnset clearfix">
			<a id="btnClose" href="#">取消</a>
			<!--<a id="btnReset" href="#">重置</a> -->
			<a id="btnSave" href="<s:property value="url" />">保存</a>
		</div>


	</body>
</html>
